#include <iostream>
#include<string>
using namespace std;

int main() 
{
    int n = 0;
    cin >> n;
    while (n--)
    {
        char s[101] = "abc";
        cin >> s;
        string str(s);
        if (str.size() < 10)
        {
            cout << s << endl;
        }
        else
        {
            cout << s[0] << str.size() - 2 << s[str.size() - 1] << endl;
        }
    }
    return 0;
}